Skip to content

Fix wrapped methods with a single positional argument - #697

Open
rsignell wants to merge 1 commit into
xarray-contrib:mainfrom
rsignell:fix-single-posarg-transpose
Open

rsignell wants to merge 1 commit into
xarray-contrib:mainfrom
rsignell:fix-single-posarg-transpose

Conversation

@rsignell

Copy link
Copy Markdown

Closes #696.

_rewrite_values returns a bare name (not a list) when a key maps to exactly one name, and _process_signature then did posargs.extend(value) for *args parameters. list.extend on a string appends its characters, so da.cf.transpose("Y") on a 1-D array failed with Dimensions {'o', 't', ...} do not exist.

The fix wraps the value with always_iterable before extending.

Test: test_pos_args_methods_single_argument (a CF axis name, a standard name and a plain dimension name on a 1-D array). It fails on main and passes with the change; the full suite passes (283 passed, 22 skipped).

This is also what breaks xroms.order, and so xroms.isoslice on 2-D variables.

🤖 Generated with Claude Code

_rewrite_values returns a bare name when a key maps to one name, and
_process_signature extended the positional args with it, unpacking the
string into characters. cf.transpose('Y') on a 1-D array therefore raised
"Dimensions {'o', 't', ...} do not exist".

Closes xarray-contrib#696

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cf.transpose with a single argument unpacks the name into characters

1 participant